<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">
      
<h:head>
	<title>Search Basic Products</title>
</h:head>

<h:body>
<p:panel>
		<h:link outcome="index" value="Home" /> <br /> 
		<h:link outcome="indexPackages" value="Packages section" /> <br /> 
        <h:link outcome="indexBasicProduct" value="Basic Products section" /> <br /> 
       	<h:link outcome = "createPackage" value = "Go To The Package!"/>
</p:panel>
 
	<h:form id="form">
     	<p:dataTable  var="residence" value="#{residenceSearch.residences}"  
     			 
     			
                filteredValue="#{residenceSearch.filtered}" 
                id="residencesTable"
                emptyMessage="There are NO Residences"
                paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
				rowsPerPageTemplate="5,10,15"
				paginator="true"
				cellSeparator="true"
				resizableColumns="true">  

  
        <p:column headerText="ID" sortBy="id" filterBy="id" id="id">  
            #{residence.id}  
        </p:column>
        
        <p:column headerText="Name" sortBy="residenceName" filterBy="residenceName" id="residenceName">  
            #{residence.residenceName}  
        </p:column>   

        <p:column headerText="City" sortBy="city" filterBy="city" id="city">  
            #{residence.city}
        </p:column> 
            
        <p:column headerText="Country" sortBy="country" filterBy="country" id="country">  
            #{residence.country}
        </p:column>    

        <p:column headerText="From" sortBy="fromDate" filterBy="fromDate" id="fromDate">  
            #{residence.fromDate}
        </p:column> 
        
        <p:column headerText="To" sortBy="toDate" filterBy="toDate" id="toDate">  
            #{residence.toDate}
        </p:column>  
        
        <p:column headerText="Price" sortBy="price" filterBy="price" id="price" >  
            #{residence.price}
        </p:column> 
        
        <p:column headerText="Stars" sortBy="stars" filterBy="stars" id="stars">  
            #{residence.stars}
        </p:column>  
        
   		<p:column style="width:32px"> 
   		<f:facet name="header">
   		<input type='button' value="*" readonly="readonly" title='View Details!' />
   		</f:facet > 
             <p:commandButton id="det"  update=":dlgForm:resDetGrid" oncomplete="resDialog.show()"  
        		     image="ui-icon ui-icon-search" style="width:32px">  
              
                 <f:setPropertyActionListener value="#{residence}"  
                     target="#{residenceSearch.currentResidence}" />  
                     
             </p:commandButton>  
             
         </p:column>
         <p:column style="width:32px">
           <f:facet name="header">
   		<input type='button' value="*" readonly="readonly" title='Delete Product!' />
   		</f:facet > 
                      <p:commandButton id="resDelete"  icon="ui-icon-trash" style="width:32px"
             update=":form:residencesTable"  ajax="false" action="#{residenceSearch.deleteResidence()}">
                               <f:setPropertyActionListener value="#{residence}"  
                     target="#{residenceSearch.currentResidence}" />  
                     </p:commandButton>
         </p:column>  

                 <p:column style="width:32px">
                 <f:facet name="header">
   					<input type='button' value="*" readonly="readonly" title='Add Product To The Package!' />
   				</f:facet >	 
                      <p:commandButton style="width:32px"  icon="ui-icon-disk"
       		        		 action="#{residenceSearch.addToPack()}"  ajax="false" update=":form:residencesTable">
                                                    <f:setPropertyActionListener value="#{residence}"  
                     target="#{residenceSearch.currentResidence}" />  
                     </p:commandButton>
         </p:column> 
         
            <p:column style="width:32px">
                 <f:facet name="header">
   					<input type='button' value="*" readonly="readonly" title='Add to Modify!' />
   				</f:facet >	  
 			  <p:commandButton style="width:32px"  icon="ui-icon-gear"
       		        		 action="#{residenceSearch.passToModified()}" ajax="false"
       		        		 type="submit" process="@this"
       		        		 oncomplete="modDialog.show()"
       		        		 update=":pan:modGrid" >
               <f:setPropertyActionListener value="#{residence}"  
                     target="#{residenceSearch.currentResidence}" 
                     />  
              </p:commandButton>
              
       	</p:column> 
         
      
   </p:dataTable>
 
</h:form>
    
   
    <p:dialog id="resDialog" header="Details" widgetVar="resDialog" resizable="true"  
              width="600" height="340"  showEffect="exlpode" hideEffect="explode" closeOnEscape="true">  
         <h:form id="dlgForm">
         <h:panelGrid id="resDetGrid" columns="2" >  
   
					<h:outputLabel>Available*:</h:outputLabel>
				<p:selectBooleanCheckbox value="#{residenceSearch.currentResidence.available}" disabled="true" />
			
				<h:outputLabel>Disponibility*:</h:outputLabel>
				<h:outputText value="#{residenceSearch.currentResidence.disponibility}" />
	            
	
				<h:outputLabel>Price*:</h:outputLabel>
				<h:outputText value="#{residenceSearch.currentResidence.price}" />
			
				
			
				<h:outputLabel>Residence Type*:</h:outputLabel>
				<h:outputText value="#{residenceSearch.currentResidence.type}" />  
				
				
				
				<h:outputLabel>Name*:</h:outputLabel>
				<h:outputText value="#{residenceSearch.currentResidence.residenceName}" /> 
				
				<h:outputLabel>City*:</h:outputLabel>
				<h:outputText value="#{residenceSearch.currentResidence.city}" /> 
				
				<h:outputLabel>Country*:</h:outputLabel>
				<h:outputText value="#{residenceSearch.currentResidence.country}" />
				
	
				<h:outputLabel>Address*:</h:outputLabel>
				<h:outputText value="#{residenceSearch.currentResidence.address}" />
		
				<h:outputLabel>From*:</h:outputLabel>
				<p:calendar value="#{residenceSearch.currentResidence.fromDate}" disabled="true" />
				
		
				<h:outputLabel>To*:</h:outputLabel>
				<p:calendar value="#{residenceSearch.currentResidence.toDate}" disabled="true"/>
				
		
		
				<h:outputLabel >Site:</h:outputLabel>
				<h:outputText value="#{residenceSearch.currentResidence.site}"/> 
		
	
				<h:outputLabel>Phone:</h:outputLabel>
				<h:outputText value="#{residenceSearch.currentResidence.phoneNumber}"/>
		
	
				<h:outputLabel>Rooms*:</h:outputLabel>
				<h:outputText value="#{residenceSearch.currentResidence.rooms}"/> 
		
				<h:outputLabel>Beds*:</h:outputLabel>
				<h:outputText value="#{residenceSearch.currentResidence.rooms}"/>
			
				<h:outputLabel>Stars:</h:outputLabel>
				<p:rating value="#{residenceSearch.currentResidence.stars}" disabled="true"/>  
	  
  		  
        </h:panelGrid>
        </h:form>
        
		
    </p:dialog>
    
<p:panel id="pan" header="Modify!">
		<h:form>
			<h:panelGrid columns="3" id="redGrid">
					<h:outputLabel for="available">Available*:</h:outputLabel>
					<p:selectBooleanCheckbox id="available" value="#{residenceSearch.modifiedResidence.available}" />
					<h:message for="available" />
		
					<h:outputLabel for="disponibility">Disponibility*:</h:outputLabel>
					<p:inputMask id="disponibility" value="#{residenceSearch.modifiedResidence.disponibility}" />
					<h:message for="disponibility" />
	
					<h:outputLabel for="price">Price*:</h:outputLabel>
					<p:inputMask id="price" value="#{residenceSearch.modifiedResidence.price}"  />
					<h:message for="price" />
		
					<h:outputLabel for="type">Residence Type*:</h:outputLabel>
					<p:inputText id="type" value="#{residenceSearch.modifiedResidence.type}" />
					<h:message for="type" />
	
					<h:outputLabel for="name">Name*:</h:outputLabel>
					<p:inputText id="name" value="#{residenceSearch.modifiedResidence.residenceName}"/>
					<h:message for="name" />

					<h:outputLabel for="city">City*:</h:outputLabel>
					<p:inputText id="city" value="#{residenceSearch.modifiedResidence.city}"/>
					<h:message for="city" />
					
					<h:outputLabel for="country">Country*:</h:outputLabel>
					<p:inputMask id="country" value="#{residenceSearch.modifiedResidence.country}"/>
					<h:message for="country" />

					<h:outputLabel for="address">Address*:</h:outputLabel>
					<p:inputMask id="address" value="#{residenceSearch.modifiedResidence.address}" />
					<h:message for="address" />
	
					<h:outputLabel for="fromDate">From*:</h:outputLabel>
					<p:calendar value="#{residenceSearch.modifiedResidence.fromDate}"  id="fromDate" />
					<h:message for="fromDate" />
	
					<h:outputLabel for="toDate">To*:</h:outputLabel>
					<p:calendar value="#{residenceSearch.modifiedResidence.toDate}" id="toDate"/>
					<h:message for="toDate" />
	
					<h:outputLabel for="site">Site:</h:outputLabel>
					<p:inputMask id="site" value="#{residenceSearch.modifiedResidence.site}"/>
					
					<br/>
					<h:outputLabel for="phone">Phone:</h:outputLabel>
					<p:inputMask id="phone" value="#{residenceSearch.modifiedResidence.phoneNumber}" />
					<h:message for="phone" />

					<h:outputLabel for="rooms">Rooms*:</h:outputLabel>
					<p:inputMask id="rooms" value="#{residenceSearch.modifiedResidence.rooms}" />
					<h:message for="rooms" />
	
					<h:outputLabel for="beds">Beds*:</h:outputLabel>
					<p:inputMask id="beds" value="#{residenceSearch.modifiedResidence.beds}" />
					<h:message for="beds" />
		
					<h:outputLabel for="stars">Stars:</h:outputLabel>
					<p:rating id="stars" value="#{residenceSearch.modifiedResidence.stars}" />
					<h:message for="stars" />
				</h:panelGrid>
    	    <p:commandButton disabled="residenceSearch.modifiedResidence.id==null" value="Save" icon="ui-icon-disk" ajax="false"  action="#{residenceSearch.modifyResidence()}"  type= "submit"   />
  		</h:form>
	</p:panel>

    
   
   
</h:body>
</html>